<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>JavaScript 数组 </title>
</head>
<body>
<h2>如何识别数组</h2>
<!--JavaScript 运算符 typeof 返回 "object"：-->

<p id="demo"></p>

<script>
  var fruits = ["Banana", "Orange", "Apple", "Mango"];
  document.getElementById("demo").innerHTML = typeof fruits;  //object 因为 JavaScript 数组属于对象。


//   document.getElementById("demo").innerHTML = Array.isArray(fruits);  // 返回true
  //function isArray(myArray) {return myArray.constructor.toString().indexOf("Array") > -1;}   //返回true
  //document.getElementById("demo").innerHTML = fruits instanceof Array;  //返回true
</script>
</body>
</html>